//
//  File.cpp
//  Custom Card Game
//
//  Created by Andrew Huss on 3/29/11.
//  Copyright 2011 Sonoma State University. All rights reserved.
//


#include "File.h"
using namespace std;

LinkedList::LinkedList() {
	first = NULL;
//	first = new Node;
//	first->value = 0;
//	first->next = NULL;
//	current = first;
}

LinkedList::~LinkedList() {
	Node * del;
	while (first->next != NULL) {
		del = first;
		first = first->next;
		delete del;
	}
}

LinkedList::Node::Node() {
	value = 0;
	next = NULL;
}

bool LinkedList::AddNode(int number) {
	bool added = false;
	Node * tmp;
	if(first == NULL) {
		first = new Node;
		first->value = number;
		first->next = NULL;
		added = true;
		size++;
	}
	else{
		tmp = first;
		while(tmp->next != NULL) {
			tmp=tmp->next;
		}
		tmp->next = new Node;
		tmp = tmp->next;
		tmp->value = number;
		tmp->next = NULL;
		added = true;
		size++;

	}
	return added;
}

void LinkedList::Print() {
	Node * tmp = first;
	while (tmp != NULL) {
		cout << tmp->value << endl;
		tmp = tmp->next;
	}
	cout << "Size: " << size << endl;
}